package org.example.springbootexperiment03.service;

import org.example.springbootexperiment03.dao.RegionDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * Created by bothin
 * At 2020/5/8 0:19
 * Description: 开启定时任务服务
 */
@Service
public class SchedulePlanService {
    @Autowired
    private RegionDao regionDao;

    /**
     * 【开启定时任务】 计划每天早上八点钟，爬取新的数据 cron = "0 0 8 * * *"
     * @throws IOException IO异常
     */
    @Scheduled(cron = "${region.update-cron}")
    public void pullData() throws IOException {
        regionDao.pullData();
    }
}
